{include file="public/head"/}
  
  <body>
    <div class="x-body">
        <form class="layui-form" action="{:url('admin/Shop/goodAddPro')}" method="post" enctype="multipart/form-data">
            
            
            <div class="layui-form-item">
                <label for="shop_account_name" class="layui-form-label">
                    <span class="x-red">*</span>请选择店铺:
                </label>
                <div class="layui-input-inline" style="width: 300px;">
                    <select name="shop_id" lay-filter="shop_id" id="shop_id" lay-verify="required">
                        <option value="">请选择店铺</option>
                        {foreach shoplist as $name}
                        <option value="{$name.shop_id}">{$name.shop_name}</option>
                        {/foreach}
                      </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="goods_name" class="layui-form-label">
                    <span class="x-red">*</span>商品名称:
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="goods_name" name="goods_name" required="" lay-verify="required"
                    autocomplete="off" class="layui-input"  style="width: 300px;">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="introduction" class="layui-form-label">
                    <span class="x-red">*</span>商品描述:
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="introduction" name="introduction" required="" lay-verify="required"
                    autocomplete="off" class="layui-input"  style="width: 300px;">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="price" class="layui-form-label">
                    <span class="x-red">*</span>商品价格:
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="price" name="price" required="" lay-verify="required"
                    autocomplete="off" class="layui-input"  style="width: 300px;">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="salesprice" class="layui-form-label">
                    <span class="x-red">*</span>促销价格:
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="salesprice" name="salesprice" required="" lay-verify="required"
                    autocomplete="off" class="layui-input"  style="width: 300px;">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="category_id" class="layui-form-label">
                    <span class="x-red">*</span>商品类别:
                </label>
                <div class="layui-input-inline" style="width: 300px;">
                    <select lay-filter="category_id" id="category_id" name="category_id" lay-verify="required">
                        <option value="">请选择商品类别</option>
                        {foreach $category as $list}
                        <option value="{$list.category_id}">{$list.category_name}</option>
                        {/foreach}
                      </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="pic" class="layui-form-label">
                    <span class="x-red"></span>商品图片
                </label>
                <div class="layui-input-inline">
                    <input type="file"  style="width:300px;" name="pic" id="pic">
                </div>
            </div>

            <div class="layui-form-item">
                <label for="L_repass" class="layui-form-label">
                </label>
                <button  class="layui-btn" lay-filter="add" lay-submit="">
                    添加商品
                </button>
            </div>
        </form>
    </div>

<script type="text/javascript">
    //下面用于多图片上传预览功能
    function setImagePreviews(avalue) {
        var docObj = document.getElementById("doc");
        var dd = document.getElementById("dd");
        dd.innerHTML = "";
        var fileList = docObj.files;
        for (var i = 0; i < fileList.length; i++) {
            dd.innerHTML += "<div style='float:left' > <img id='img" + i + "'  /> </div>";
            var imgObjPreview = document.getElementById("img"+i); 
            if (docObj.files && docObj.files[i]) {
                //火狐下，直接设img属性
                imgObjPreview.style.display = 'block';
                imgObjPreview.style.width = '150px';
                imgObjPreview.style.height = '180px';
                //imgObjPreview.src = docObj.files[0].getAsDataURL();
                //火狐7以上版本不能用上面的getAsDataURL()方式获取，需要一下方式
                imgObjPreview.src = window.URL.createObjectURL(docObj.files[i]);
            }else {
                //IE下，使用滤镜
                docObj.select();
                var imgSrc = document.selection.createRange().text;
                alert(imgSrc)
                var localImagId = document.getElementById("img" + i);
                //必须设置初始大小
                localImagId.style.width = "150px";
                localImagId.style.height = "180px";
                //图片异常的捕捉，防止用户修改后缀来伪造图片
                try{
                    localImagId.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale)";
                    localImagId.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = imgSrc;
                }catch(e){
                    alert("您上传的图片格式不正确，请重新选择!");
                    return false;
                }
                imgObjPreview.style.display = 'none';
                document.selection.empty();
            }
        }
        return true;
    }
</script>

    <script>
        var _hmt = _hmt || []; (function() {
            var hm = document.createElement("script");
            hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
            var s = document.getElementsByTagName("script")[0];
            s.parentNode.insertBefore(hm, s);
        })();
    </script>
    </body>
</html>